<template>
  <el-table
    ref="familyTable"
    :data="tableData"
    @row-click="rowClick"
    @selection-change="changeSelect"
    v-loading="loading"
    highlight-current-row
    style="width: 100%;margin-right:10px;"
  >
    <el-table-column type="selection"  width="50"> </el-table-column>
    <el-table-column type="index" width="50" label="序号">
    </el-table-column>
    <el-table-column property="zdzwmc" label="字段名称">
    </el-table-column>
    <el-table-column property="oldv" label="原值"> </el-table-column>
    <el-table-column property="xzv" label="现值"> </el-table-column>
  </el-table>
</template>
<script>
module.exports = {
  name: "familylist",
  props:{
    changeperson:{
      type: Function,
      default: null
    }
  },
  data() {
    return {
      tableData: [],
      chooseArr: [],
      selectStr: "",
      openRow: [],
      loading: false
    };
  },
  methods: {
    // 点击表格行
    rowClick(row) {
      // this.changePerson(row);
      // this.openRow = [row.newDto.pcc001];
    },
    // 设置第一行为高亮
    highlight(row){
      // this.$refs.familyTable.setCurrentRow(row);
    },
    selectAll(){
      this.$nextTick(function () {
        this.tableData.forEach((row) => {
          this.$refs.familyTable.toggleRowSelection(row, true)
        })
      });

    },
    // 监听多选框
    changeSelect(selection) {
      this.chooseArr = selection;
      if (selection.length == 0) {
        this.selectStr = "";
      } else {
        for (let i = 0; i < selection.length; i++) {
          if (i == 0) {
            this.selectStr = selection[i].colName;
          } else {
            this.selectStr = this.selectStr + "," + selection[i].colName;
          }
        }
      }
    },
  },
};
</script>
